import requests


class IhrmApi:

    @classmethod
    def login(cls, param):
        resp = requests.post(url="http://ihrm-test.itheima.net/api/sys/login", json=param)
        return resp

    @classmethod
    def add_emp(cls, token, param):
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url="http://ihrm-test.itheima.net/api/sys/user", headers=header, json=param)
        return resp

    @classmethod
    def query_emp(cls, token, emp_id):
        header = {"Authorization": token}
        resp = requests.get(url="http://ihrm-test.itheima.net/api/sys/user/"+emp_id, headers=header)
        return resp

    @classmethod
    def update_emp(cls, token, emp_id,param):
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url="http://ihrm-test.itheima.net/api/sys/user/"+emp_id, headers=header, json=param)
        return resp

    @classmethod
    def delete_emp(cls, token, emp_id):
        header = {"Authorization": token}
        resp = requests.get(url="http://ihrm-test.itheima.net/api/sys/user/" + emp_id, headers=header)
        return resp
